<script >
export default{
    data(){
        return{
            id:2
        }
    },
    created(){
        //监听路由参数变化，和前置守卫一样
        this.$watch(()=>
        this.$route.params,
        (toParams,previousParams)=>{
            console.log(toParams);
            console.log(previousParams);

        })
        console.log('6');
    }
}
</script>

<template>  
<div>
    home-
    {{ $route.params.id }}
    <br>
    <RouterLink to="/home/2">首页切换2</RouterLink>
    <br>
    <RouterLink to="/home/1">首页切换1</RouterLink>
    <br>
    <RouterLink to="/">返回</RouterLink>
</div>
</template>

<style scoped>

</style>
